package cemp.mapper;

import cemp.entity.StockSysUser;
import cemp.entity.StockThsGnStocks;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author xsb_t
* @description 针对表【stock_ths_gn_stocks】的数据库操作Mapper
* @createDate 2025-10-05 14:18:47
* @Entity cemp.entity.StockThsGnStocks
*/
public interface StockThsGnStocksMapper extends BaseMapper<StockThsGnStocks> {

    @Select("select distinct stock_code,per,vol_ratio,total_capital  from stock_ths_gn_stocks where create_time = #{tradeDate}")
    List<StockThsGnStocks> getDistinctList(@Param("tradeDate")String tradeDate);

    @Select("select min(id) as id , t1.gn_code,t1.stock_code from stock_ths_gn_stocks t1 group by t1.gn_code,t1.stock_code having count(*) > 1")
    List<StockThsGnStocks> getDuplicate();

    @Insert("INSERT INTO stock_ths_gn_stocks_history (stock_code, gn_code, stock_name,create_time)\n" +
            "SELECT stock_code, gn_code, stock_name,create_time\n" +
            "FROM stock_ths_gn_stocks")
    Integer merge2History();
}




